/**
 * 点播列表js
 */
var vo={};
$(function(){
	var openWindow=window.document;
	$("#demandList").height($(openWindow).height()-$(openWindow).height()*0.05-85);
	setInterval(function(){
		$("#demandList").width(window.parent.$("#centerIframe").width()-124);
	},1000)
	var date=new Date();
	$("#openStartDate").datebox({
		editable:false
	});
	$("#openStartDate").datebox('setValue',Common.formatterDate(date));
	$("#openStopDate").datebox({
		editable:false
	});
	$("#openStopDate").datebox('setValue',Common.formatterDate(date));
	var data=[{"id":"casename","text":"案件名称"},
	          {"id":"casecode","text":"案件编号"},
	          {"id":"judgerchief","text":"审判长"},
	          {"id":"opencourt","text":"开庭地点"}
	         ]
	$("#searchsort").combobox({
		 data:data,
		 valueField:'id',
		 textField:'text',
		 editable:false,
		 panelHeight:"auto",
		 onLoadSuccess:function(data){
			 $("#searchsort").combobox('select',data[0].id);
		 },
	 })
	 $("#demandList").datagrid({
			url:$Path+'/admin/demand/getList?status=1',
			method:'GET',
			pagination:true,
			pageList: window.PageSize,
			loadMsg:'加载中......',
			fitColumns:true,
//			nowrap:true,
			sortName:"opendate",
			sortOrder:"desc",
			singleSelect:true,
			columns:[[
					 {field:'casename',title:'案件名称', align:'center',width:200},
			         {field:'casecode',title:'案件编号', align:'center',width:100},
			         {field:'judgerchief',title:'审判长', align:'center',width:100},
			         {field:'opencourt',title:'开庭地点', align:'center',width:100},
			         {field:'opendate',title:'开庭日期', align:'center',width:100,formatter:function(value,row,index){
			        	if(value!=''&&value!=undefined){
			        		return Common.formatterDate(value);
			        	}
			        	else{
			        		return "";
			        	}
			         }},
			         {field:'rowid' ,align:'center',title:'操作',width:100,formatter: function(value, row, index){
						 var ref="";
						 if(row.status=='1'||row.status=='0'||row.status=='4'){
							 ref+='<img src="'+$Path+'/public/images/icon_demand.png" title="直播" class="easyui-tooltip" onclick="demandView(\''+row.caseid+'\',\''+row.courtid+'\')">';
						 }
						 if(row.status=='2'){
							 ref+='<img src="'+$Path+'/public/images/icon_replay.png" title="回放" class="easyui-tooltip" onclick="demandReplay(\''+row.caseid+'\')">';
						 }
//						 if(row.status=='3'){
//							 ref+='<img src="'+$Path+'/public/images/keyword_major.png" title="关键词优化" class="easyui-tooltip" onclick="keyword(\''+row.caseid+'\',\''+row.courtid+'\')">';
//						 }
						 return ref;
					 }}
			     ]]
		});
})
/**
 * 跳转到直播配置页
 * @param caseid
 * @param courtid
 */
function demandView(caseid,courtid){
	window.parent.opentab('02001','庭审直播','/admin/court_begin','caseid='+caseid+'&courtid='+courtid);
}
/**
 * 跳转到直播配置页
 * @param caseid
 * @param courtid
 */
function demandReplay(caseid){
	window.parent.opentab('02001','庭审点播','/admin/court_replay','caseid='+caseid);
}
/**
 * 跳转到关键词优化
 * @param caseid
 * @param courtid
 */
function keyword(caseid,courtid){
	window.parent.opentab('02001','关键词优化','/admin/keywords_major','caseid='+caseid+'&courtid='+courtid);
}
/**
 * 查询
 */
function searchCase(){
	vo.beginDate=$("#openStartDate").datebox('getValue');
	vo.endDate=$("#openStopDate").datebox('getValue');
	if(vo.beginDate>vo.endDate){
		parent.$.messager.alert('警告',"开始时间不可大于结束时间",'warning');
		return false;
	}
	vo.searchsort=$("#searchsort").combobox('getValue');
	vo.searchText=$("#searchText").val();
	$("#demandList").datagrid('load',vo);
}